<template>
	<view class="container">
		<view class="tui-qrcode__box" :style="{ paddingTop: height + 18 + 'px' }">
			<image :src="QRcodeSrc" style="width: 400rpx;height: 400rpx; margin: 10px auto; display: block;"
				mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	import {
		appId,
	} from '@/util/config'
	import {
		getQrCodeImgUrl,
		addPublicize
	} from '../../api/user.js'
	export default {
		data() {
			return {
				// shareImg: 'https://thorui.cn/extend/share/share_img_qrcode.png',
				height: 20,
				top: 12,
				winWidth: 375,
				winHeight: 667,
				posterImg: '',
				QRcodeSrc: '',
			};
		},
		onLoad(options) {
			// let param = {
			// 	openId: '',
			// 	promoterOpenId: ''
			// }
			// addPublicize(param, 'post').then(res => {
			// 	console.log(res, 111111111112222222);
			// })
		},
		onReady() {
			this.createQrCode()
		},
		methods: {
			createQRCode() {
				let that = this
				getQrCodeImgUrl({
					scene: `${uni.getStorageSync('user').openid}`,
					folder: 'order'
				}, 'get').then(res => {
					that.QRcodeSrc = 'data:image/png;base64,' + res
				})
				
			},
			createQrCode() {
				console.log("生成专属二维码")
				if (this.QRcodeSrc) {
					this.showQrcode = true
				} else {
					this.showQrcode = false
					this.createQRCode()
				}
			},
		},
	};
</script>

<style>
	page,
	.container {
		height: 100%;
		background: linear-gradient(to right, #ffcb4b, #ffae34);
	}

	.tui-share__back {
		position: absolute;
		left: 12rpx;
	}

	.tui-qrcode__box {
		width: 100%;
		display: flex;
		justify-content: center;
	}

	.tui-qrcode__ic {
		width: 648rpx;
		height: 774rpx;
	}

	.tui-share__box {
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		color: rgba(255, 255, 255, 0.85);
		font-size: 28rpx;
		padding-bottom: 56rpx;
	}

	.tui-share__title {
		color: rgba(255, 255, 255, 0.6);
		padding-bottom: 12rpx;
	}

	.tui-share__list {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.tui-share__item {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		padding: 40rpx 60rpx;
		position: relative;
	}

	.tui-share__ic {
		width: 80rpx;
		height: 80rpx;
		margin-bottom: 12rpx;
		opacity: 0.85;
	}

	.tui-poster__canvas {
		background-color: #fff;
		position: absolute;
		left: -9999px;
	}
</style>